
package com.be.beadmin.design.repository;

import com.be.beadmin.design.entity.StandProduct;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
* @author Jiahao Liu
* @date 2023-02-13
**/
public interface StandProductRepository extends JpaRepository<StandProduct, String>, JpaSpecificationExecutor<StandProduct> {

    StandProduct findStandProductByIdAndDelete(String id, Integer delete);

    StandProduct findStandProductById(String id);

    StandProduct findStandProductByStandTypeCode(String standTypeCode);

    StandProduct findStandProductByStandTypeCodeAndDelete(String standTypeCode,int delete);

    StandProduct findStandProductByStandBomFileCode(String standBomFileCode);

    StandProduct findStandProductByStandDrawingFileCode(String standDrawingFileCode);

    @Query(value = "select sp.stand_type_code from t_dm_stand_product sp where sp.is_delete=0",nativeQuery = true)
    List<String> findStandProductCodes();

    @Query(value = "select sp.stand_type_code from t_dm_stand_product sp where sp.stand_type_desc=?1 and sp.is_delete=?2",nativeQuery = true)
    List<String> findStandProductCodesByStandTypeDescAndDelete(String standTypeDesc,int delete);

    List<StandProduct> findStandProductByStandTypeDescAndDelete(String standTypeDesc,int delete);

    StandProduct findStandProductByStandTypeNameAndDelete(String standTypeName ,int delete);

    List<StandProduct> findStandProductByBopCodeAndDelete(String bopCode, int delete);

    List<StandProduct> findStandProductByStandTypeDescAndStateAndDelete(String productType, int state, int delete);
}